<?php
class Msection extends CI_Model{
	protected $_table="tpt_section";
	public function __construct(){
		parent::__construct();	
		$this->load->database();
	}
    
	public function listSection($arrCol){
        $this->db->select(implode(',',$arrCol));
        return $this->db->get($this->_table)->result_array();    
    }

    public function list_all(){
		return $this->db->get($this->_table)->result_array();
    }

    public function insert($data){
        $this->db->insert($this->_table,$data);
    }

    public function check_name($name,$id = ""){
        if($id != ""){
            $this->db->where("id !=",$id);
        }
        $this->db->where("name",$name);
        $query = $this->db->get($this->_table);
        if($query->num_rows() == 0){
            return TRUE;
        }else{
            return FALSE;
        }
    }

    public function get_data($id){
        $this->db->where('id',$id);
        return $this->db->get($this->_table)->row_array();
    }

    public function update($data,$id){
        $this->db->where('id',$id);
        $this->db->update($this->_table,$data);
    }

    public function delete($id){
        $this->db->where('id',$id);
        $this->db->delete($this->_table,$data);
    }
		
	public function get_name($sec_url){
		$this->db->where('url',$sec_url);
		return $this->db->get($this->_table)->row_array();
	}
}